package conf

import (
	"fmt"
	"github.com/spf13/viper"
)

type Conf struct {
	Mysql struct {
		User     string
		Pass     string
		Port     string
		Hort     string
		Database string
	}
}

var Dsn string

func Init() {
	var db Conf
	viper.SetConfigFile("./conf/conf.yaml")
	viper.ReadInConfig()
	viper.Unmarshal(&db)
	fmt.Println(db)
	Dsn = fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8&parseTime=True&loc=Local", db.Mysql.User, db.Mysql.Pass, db.Mysql.Port, db.Mysql.Hort, db.Mysql.Database)
	fmt.Println(Dsn)
}
